'use strict'

const {logger} = require('ee-core/log')
const {app: electronApp} = require('electron')

/**
 * 安全插件
 */
class SecurityService {
    /**
     * 创建
     */
    create() {
        logger.info('[security] load')
        const runWithDebug = process.argv.find(function (e) {
            return e.includes("--inspect") || e.includes("--inspect-brk") || e.includes("--remote-debugging-port")
        })

        // 不允许远程调试
        if (runWithDebug) {
            logger.error('[SecurityService] Remote debugging is not allowed,  runWithDebug:', runWithDebug)
            electronApp.quit()
        }
    }
}

SecurityService.toString = () => '[class SecurityService]'
module.exports = {
    securityService: new SecurityService()
}